package oop.a01oop.a01Polymorphism;

public class Test {
    public static void main(String[] args) {
       Animal a = new Animal();
       //a.eat();
       //a.lookHome();

//       Dog d = (Dog) a;
//       d.lookHome();

       if (a instanceof Dog dog){
           dog.lookHome();
       }else if (a instanceof Cat cat){
         cat.lickHair();
       }else {
           System.out.println("类型不存在");
       }

    }
}

class  Animal{
    public void  eat(){
        System.out.println("动物在吃东西");
    }
}

class Dog extends Animal{
    public void eat(){
        System.out.println("吃骨头");
    }

    public  void  lookHome(){
        System.out.println("看家");
    }
}


class Cat extends Animal{
    public void eat(){
        System.out.println("吃鱼");
    }

    public void lickHair(){
        System.out.println("舔毛");
    }
}